<!--  初始化判断当前是否登录   -->
$(function () {
    $.ajax({
        type: 'get',
        url: '/admin/loginAdmin',
        success: function (adminJSON) {
            if (adminJSON.message == "error") {
                layui.layer.msg('请登录！',{icon:0,time:1000,end:function () {
                        location.href='/html/admin/login.html';
                    }});
                return;
            }
            //存储管理员Id、name，用户数据回显查询
            sessionStorage.setItem("aId",adminJSON.object.id);
            sessionStorage.setItem("name",adminJSON.object.name);
            // 将登录用户名回显
            var name = adminJSON.object.name;
            $("#admin").html(name);
            return;
        },
        error: function () {
            return;
        }
    });
});
function destroyLogin() {
    $.get('/admin/destroyLogin',{},function (data) {
        // console.log("退出登录"+data.message+"\n"+data.state)
        if (data.message == "success") {
            sessionStorage.removeItem("name");
            location.href='/html/admin/login.html';
            return false;
        }
        layui.layer.msg('退出失败，请稍后重试！',{icon:0,time:1000});
        return false;
    })

}